package com.gdzl_hadoop.controller;

import com.gdzl_hadoop.common.ServerResponse;
import com.gdzl_hadoop.service.IExecuteAlgorithmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.File;

/**
 * Created by 1032019725 on 2017/10/18.
 */
@Controller
@RequestMapping("/algorithm/")
public class AlgorithmController {

    @Autowired
    private IExecuteAlgorithmService iExecuteAlgorithmService;
    @ResponseBody
    @RequestMapping(value = "FPG.do")
    public ServerResponse<String> executeFPGAlgorithm(String guid){

        return iExecuteAlgorithmService.executeFPG(guid);
    }

    /**
     * by LRB
     *
     * @param servletRequest
     * @param year
     * @param xzqdm
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "FPG2.do")
    public ServerResponse<String> executeFPGAlgorithm(HttpServletRequest servletRequest, String year, double minSupPro, String xzqdm) {
        String pathRoot = servletRequest.getSession().getServletContext().getRealPath("") + "\\upFileDir\\" + year + File.separator + xzqdm;
        return iExecuteAlgorithmService.executeFPG(year, xzqdm, minSupPro, pathRoot);
    }


    @ResponseBody
    @RequestMapping(value = "HLXFX.do")
    public ServerResponse<String> executeHLXFXAlgorithm(String guid){
        return iExecuteAlgorithmService.executeHLXFX(guid);
    }

    @ResponseBody
    @RequestMapping(value = "RandomForest.do")
    public ServerResponse<String> executeRandomForestAlgorithm(String guid){
        return iExecuteAlgorithmService.executeRandomForest(guid);
    }




}
